home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_061 / microemacs / magic.doc < prev    next >
Text File  |  1992-05-06  |  4KB  |  82 lines

  1.  
  2.         Some notes on the MAGIC mode.
  3.  
  4.      In the MAGIC mode of MicroEmacs (versions 3.8 and up),
  5. certain characters gain special meanings when used in a search
  6. pattern.  Collectively they are know as regular expressions,
  7. and a limited number of them are supported in MicroEmacs.
  8. They grant greater flexability when using the search command.
  9. However, they do not affect the incremental search command.
  10.  
  11.      The symbols that have special meaning in MAGIC mode are
  12. ^, $, ., *, [ (and ], used with it), and \.
  13.  
  14.      The characters ^ and $ fix the search pattern to the
  15. beginning and end of line, respectively.  The ^ character
  16. must appear at the beginning of the search string, and the
  17. $ must appear at the end, otherwise they loose their
  18. meaning and are treated just like any other character.
  19. For example, in MAGIC mode, searching for the pattern
  20. "t$" would put the cursor at the end of any line that ended
  21. with the letter 't'.  Note that this is different than
  22. searching for "t<NL>", that is, 't' followed by a newline
  23. character.  The character $ (and ^, for that matter) matches
  24. a position, not a character, so the cursor remains at the end
  25. of the line.  But a newline is a character that must be matched,
  26. just like any other character, which means that the cursor is
  27. placed just after it - on the beginning of the next line.
  28.  
  29.      The character . has a very simple meaning - it matches
  30. any single character, except the newline.  Thus a search for
  31. "bad.er" could match "badger", "badder" (slang), or up to the
  32. 'r' of "bad error".
  33.  
  34.      The character * is known as closure, and means that zero
  35. or more of the preceding character will match.  If there is
  36. no character preceding, * has no special meaning, and since
  37. it will not match with a newline, * will have no special
  38. meaning if preceded by the beginning of line symbol ^ or
  39. the literal newline character <NL>.
  40.      The notion of zero or more characters is important.
  41. If, for example, your cursor was on the line
  42.  
  43.     This line is missing two vowels.
  44.  
  45. and a search was made for "a*", the cursor would not move,
  46. because it is guarenteed to match no letter 'a' , which
  47. satifies the search conditions.  If you wanted to search
  48. for one or more of the letter 'a', you would search for
  49. "aa*", which would match the letter a, then zero or more of
  50. them.
  51.  
  52.      The character [ indicates the beginning of a character
  53. class.  It is similar to the 'any' character ., but you get
  54. to choose which characters you want to match.  The character
  55. class is ended with the character ].  So, while a search for
  56. "ba.e" will match "bane", "bade", "bale", "bate", et cetera,
  57. you can limit it to matching "babe" and "bake" by searching
  58. for "ba[bk]e".  Only one of the characters inside the [ and ]
  59. will match a character.  If in fact you want to match any
  60. character except those in the character class, you can put
  61. a ^ as the first character.  It must be the first character
  62. of the class, or else it has no special meaning.  So, a
  63. search for [^aeiou] will match any character except a vowel,
  64. but a search for [aeiou^] will match any vowel or a ^.
  65. If you have a lot of characters in order that you want to
  66. put in the character class, you may use a dash (-) as a
  67. range character.  So, [a-z] will match any letter (or any
  68. lower case letter if EXACT mode is on), and [0-9a-f] will
  69. match any digit or any letter 'a' through 'f', which happen
  70. to be the characters for hexadecimal numbers.  If the dash is
  71. at the beginning or end of a character class, it is taken to
  72. be just a dash.
  73.  
  74.      The escape character \ is for those times when you want to be in
  75. MAGIC mode, but also want to use a regular expression character
  76. to be just a character.  It turns off the special meaning of the
  77. character.  So a search for "it\." will search for a line with "it.",
  78. and not "it" followed by any other character.  The escape character
  79. will also let you put ^, -, or ] inside a character class with no
  80. special side effects.
  81.  
  82.